home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Annotations
/
Append Calibrator
< prev
next >
Wrap
Text File
|
1994-02-18
|
4KB
|
115 lines
#include <Strings as Lists>
#include <Axis Utilities>
Function InitCalibratorGlobals()
String/G u_xaxis="bottom",u_yaxis="left"
Variable/G/D u_dx=1,u_dy=1
Variable/G u_orient=1,u_label=1 | upper-left, print
End
Macro Calibrator(xaxis,yaxis,dx,dy,orient,label)
String xaxis=u_xaxis,yaxis=u_yaxis
Variable/D dx=u_dx,dy=u_dy
Variable orient=u_orient,label=u_label
Prompt xaxis,"X axis (horizontal axis)",popup,HVAxisList("",1) | only horizontal axes
Prompt yaxis,"Y axis (vertical axis)",popup,HVAxisList("",0) | only vertical axes
Prompt dx,"calibrator X length, or 0 for none"
Prompt dy,"calibrator Y length, or 0 for none"
Prompt orient,"Orientation",popup,"upper-left;upper-right;lower-right;lower left;"
Prompt label,"print values",popup,"don’t print;print;print with units;print with units and ,K,m,µ etc"
PauseUpdate;Silent 1
u_xaxis=xaxis;u_yaxis=yaxis
u_dx=dx;u_dy=dy
u_orient=orient;u_label=label
FCalibrator(xaxis,yaxis,dx,dy,orient,label)
End
| Replace "Function" with "Macro" to reduce compile time
Function FCalibrator(xaxis,yaxis,dx,dy,orient,label)
String xaxis,yaxis
Variable/D dx,dy
Variable orient,label | see popup list of Calibrator macro for label values (1 is don't print, etc)
| Put calibrator in upper right corner of graph
Variable/D xorig,yorig | corner of calibrator
Variable/D px,py | polygon origin
Variable/D hx,hy,vx,vy | text origins
Variable/D sf=0.15 | inset from upper-right corner
GetAxis/Q $xaxis;xorig=V_max-(V_max-V_min)*sf
GetAxis/Q $yaxis;yorig=V_max-(V_max-V_min)*sf
GraphNormal | Forces deselection
SetDrawEnv gstart | gstart can't be on next line!
SetDrawEnv xcoord= $xaxis,ycoord= $yaxis, fillpat=0,linethick=3
if(orient == 1) | upper-left
xorig -= dx
hx= xorig + dx/2
vy= yorig - dy/2
px= xorig;py=yorig-dy
DrawPoly px,py, 1, 1, {0,0,0,dy,dx,dy}
endif
if(orient == 2) | upper-right
hx= xorig - dx/2
vy= yorig - dy/2
px= xorig-dx;py=yorig
DrawPoly px,py, 1, 1, {0,0,dx,0,dx,-dy}
endif
if(orient == 3) | lower-right
yorig -= dy
hx= xorig - dx/2
vy= yorig + dy/2
px= xorig;py=yorig+dy
DrawPoly px,py, 1, 1, {0,0,0,-dy,-dx,-dy}
endif
if(orient == 4) | lower left
xorig -= dx
yorig -= dy
hx= xorig + dx/2
vy= yorig + dy/2
px= xorig+dx;py=yorig
DrawPoly px,py, 1, 1, {0,0,-dx,0,-dx,dy}
endif
String labelVal,fmt,units
| horizontal calibrator value
if( (dx != 0)%& (label>1) ) | label == 1 is don't print
units= AxisUnits(xaxis)
fmt="%g"
if( (label== 3) %& (strlen(units)>0) ) | 3 is print with units
fmt += " "+units
endif
if(label == 4) | 4 is print with units and prefixes
fmt="%.1W1P"+units | change %.1 to number of digits after decimal point you want (%.2 is two digits, etc)
endif
sprintf labelVal, fmt, dx
hy = yorig
Variable yj=0 | bottom
if( orient >= 3 )
yj= 2 | top
endif
SetDrawEnv xcoord= $xaxis,ycoord= $yaxis,textxjust= 1,textyjust=yj
DrawText hx,hy, labelVal
endif
| vertical calibrator value
if( (dy != 0)%& (label>1) )
units= AxisUnits(yaxis)
fmt="%g"
if( (label== 3) %& (strlen(units)>0) )
fmt += " "+units
endif
if(label == 4)
fmt="%.1W1P"+units
endif
sprintf labelVal, fmt, dy
vx= xorig
Variable xj=0,rot=0 | left | use rot= -90 for top-to-bottom
if( (orient == 1) %| (orient == 4) ) |"upper-left; upper-right;lower-right;lower left;"
xj= 2 |right use rot=90 for bottom-to-top
endif
SetDrawEnv xcoord= $xaxis,ycoord= $yaxis,textxjust= xj,textyjust=1,textrot=rot
DrawText vx,vy, " "+labelVal+" " | extra spaces to keep label away from line
endif
SetDrawEnv gstop
End